<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>发布任务</title>
    <!-- 基本框架 -->
    <link rel="stylesheet" href="../../../css/common.css">
    <script src="../../../script/vue.min.js" type="text/javascript"></script>
    <script src="../../../script/frame.js" type="text/javascript"></script>
    <script src="../../../script/baseConfig.js" type="text/javascript"></script>
    <script src="../../../script/utils.js" type="text/javascript"></script>
    <script src="../../../script/common.js" type="text/javascript"></script>
    <style>
        body{
            background: rgba(0,0,0,0);
        }
		
        .container{
            padding: 0 5%;
        }
        .pushTask_small_title{
            font-weight: 400;
            font-size: .35rem;
            font-weight: 500;
            margin-top: .4rem;
            color: #000;
        }
        .pushTaskList {
			margin:0px -0.2rem;
            margin-top: .5rem;
        }
        .pushTaskList li {
            width: 25%;
            float: left;
            margin-bottom: .35rem;
            color: #a2a2a2;
            font-size: .27rem;
			font-weight: lighter;
            text-align: center;
        }
        .pushTaskList  img {
            display: block;
            margin: 0 auto .2rem;
            width: .85rem;
            height: .85rem;
        }
    </style>
</head>
<body>
    <div id="app" v-cloak>
        <div class="container" v-if="subJectList!=null">
            <div
                v-for="(subjectItem,subjectIndex) of subJectList"
                :key="subjectIndex+ 'subject'"
            >
                <h3 class="pushTask_small_title"> 
                    {{
                        subjectItem.name
                    }}
                </h3>
                <ul class="pushTaskList clearfix"
                > 
                    <li
                        v-for="(projectItem,projectIndex) of subjectItem.project"
                        :key="projectIndex+ 'project'"
                        @click="navPush(projectItem)"
                    >
                        <img :src="projectItem.icon.url" alt="">
                        <span>
                            {{projectItem.name}}
                        </span>
                    </li>
                </ul>
            </div>
        </div>
		<template v-else>
		    <div class="loadFull whiteBg pageload">
		        <div class="se-loading"></div>
		    </div>
		</template>
    </div>
    <script type="text/javascript">
        apiready = function() {
            var app = new Vue({
                el:'#app',
                data:{
					subJectList:null,
					iosTest:false,
                },
                created() {
                    this.getSubjectApi();
                },
                methods:{
                    getSubjectApi: function(){
                        var _self = this;
                        $.comRequest('get','/task/projects_group_by_platform',{},function(res){
                            var subJectList = [];
                            var platforms = res.data.platforms;
                            var projects = res.data.projects;
                            for(var i=0;i<platforms.length;i++){
                                var curSubject = platforms[i];

                                curSubject.project = [];
                                if (projects[curSubject.id]) {
                                    curSubject.project = projects[curSubject.id];
                                }
                                subJectList.push(curSubject);

                            }
                            _self.subJectList = subJectList;
                        },function(ero){
                            $.toast(ero.message);
                        });
                    },
                    navPush: function(projectItem) {
                        $.handleLocalStorage.set('pushProject',projectItem);
                        $.openUrl('common/commonTitle','push/pushLink',{
                            title: '发布任务',
                            tpid: projectItem.id,
                            name: projectItem.platform.name,
                            titles: projectItem.name,
                            minAmount: projectItem.min_amount,
                            minNum: projectItem.min_total_accept,
                            publishTips: projectItem.publish_tip,
                            tipsKey: projectItem.platform.id+'_'+projectItem.id,
                        });
                    }
                },
                mounted(){
					$.initJs(this);
                }
            });
			
			
			//下拉刷新
			$.pullDown({
			    success:function(){
			        app.getSubjectApi();
			    }
			});
        }
    </script>
</body>
</html>
